﻿///***************************************************************
/// 시  스  템 : Updms.Common.Inc
/// 단위시스템 : INC
/// 계      층 : Presentation Layer
/// 프로그램명 : TabTitle
/// 파  일  명 : TabTitle.ascx.cs
/// 설      명 : 탭타이틀
///***************************************************************
/// 수정ID 일자       이름     내용
///---------------------------------------------------------------
/// CH001  2008-09-23 송시명   최초 작성
///***************************************************************
using System;
using System.Data;
using System.Text;

using SMFramework.Data;
using SMFramework.Utility;

using Base.Dac;

using Updms.Com.Exe;


namespace Updms.Common.Inc
{
	public partial class TabTitle : System.Web.UI.UserControl
	{
		#region 전역영역
		
		Global global = new Global();
		
		public string tagPrefixs = string.Empty;
		protected string gs_pgm_id = "";
		protected string gs_lang_set = "";

		//페이지모드
		private string gs_page_mode = "";

		//프로퍼티
		public string TagPrefixs
		{
			set { tagPrefixs = value; }
		}
		
		#endregion

		#region Page_Load

		protected void Page_Load(object sender, EventArgs e)
		{
			gs_pgm_id = tagPrefixs;
			gs_lang_set = Session["Lang_Set"].ToString().Trim();
			gs_page_mode = (Request.QueryString["page_mode"] == null || Request.QueryString["page_mode"].Trim().Length == 0)
					? "" : Request.QueryString["page_mode"].ToString();
		}
		
		#endregion

		#region SetTabTitle
		
		public String SetTabTitle()
		{
			DataSet lo_ds = new DataSet();
			DataPack lo_dp = new DataPack();
			StringBuilder sb = new StringBuilder();

			lo_dp.AddProperty("ls_pgm_id", typeof(string), gs_pgm_id);
			lo_dp.AddProperty("ls_lang_set", typeof(string), gs_lang_set);

			sb.Append("<table id=\"tab_title\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" border=\"0\">\r\n");
			sb.Append("\t\t\t\t<tr>\r\n");

			//팝업모드로 열리면 global.GetMenuTitle에서 조회
			if (gs_page_mode.ToUpper() == "P")
			{
				sb.Append("\t\t\t\t\t<td class=\"margin\">&nbsp;</td>\r\n");
				sb.Append("\t\t\t\t\t<td class=\"on\">" + global.GetMenuTitle(gs_pgm_id, gs_lang_set) + "</td>\r\n");
			}
			else
			{
				using (Com1016m_NT _Com1016m_NT = new Com1016m_NT())
				{
					lo_ds.Merge(_Com1016m_NT.GetTabTitle(lo_dp));
				}

				int li_cnt = DataSetUtil.GetRowCount(lo_ds, "UPDMS_COM_PGM_TAB_TITLE");

				//탭타이틀이면
				if (li_cnt > 0)
				{
					for (int i = 0; i < li_cnt; i++)
					{
						string ls_pgm_id = DataSetUtil.GetFldStr(lo_ds, "UPDMS_COM_PGM_TAB_TITLE", i, "Pgm_Id");
						string ls_link = DataSetUtil.GetFldStr(lo_ds, "UPDMS_COM_PGM_TAB_TITLE", i, "Link");
						string ls_title = DataSetUtil.GetFldStr(lo_ds, "UPDMS_COM_PGM_TAB_TITLE", i, "Title");
						string ls_sm = DataSetUtil.GetFldStr(lo_ds, "UPDMS_COM_PGM_TAB_TITLE", i, "Sm");

						string ls_link_title = "<a href=\"" + ls_link + ls_sm + "\">" + ls_title + "</a>";

						sb.Append("\t\t\t\t\t<td class=\"margin\">&nbsp;</td>\r\n");

						//선택한 프로그램
						if (ls_pgm_id == gs_pgm_id)
						{
							sb.Append("\t\t\t\t\t<td class=\"on\">" + ls_title + "</td>\r\n");
						}
						else
						{
							sb.Append("\t\t\t\t\t<td class=\"off\">" + ls_link_title + "</td>\r\n");
						}
					}
				}
				else
				{
					sb.Append("\t\t\t\t\t<td class=\"margin\">&nbsp;</td>\r\n");
					sb.Append("\t\t\t\t\t<td class=\"on\">" + global.GetMenuTitle(gs_pgm_id, gs_lang_set) + "</td>\r\n");
				}
			}

			sb.Append("\t\t\t\t\t<td class=\"right\">&nbsp;</td>\r\n");
			sb.Append("\t\t\t\t</tr>\r\n");
			sb.Append("\t\t\t</table>");
					
			return sb.ToString();
		}

		#endregion
	}
}